package com.manage.controller;

import com.clms.common.R;
import com.manage.pojo.entity.TbClient;
import com.manage.pojo.vo.ClientVo;
import com.manage.pojo.vo.UniqueVo;
import com.manage.service.ClientService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @program: clms-third
 * @description: 客户控制层
 * @author: 林子洁
 * @create: 2021-07-22 14:41
 **/
@RestController
@RequestMapping("/manage/client")
public class ClientController {
    @Resource
    private ClientService clientService;

    @PostMapping("/initClient/{currentPage}/{pageSize}")
    public R initClient(@PathVariable("currentPage") Integer currentPage,
                        @PathVariable("pageSize") Integer pageSize,
                        @RequestBody ClientVo clientVo) {
        System.out.println(currentPage + pageSize);
        return clientService.initClient(currentPage, pageSize, clientVo);
    }

    @PostMapping("/insertClient")
    public R insertClient(@RequestBody TbClient client) {
        return clientService.insertClient(client);
    }

    @GetMapping("/updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable("id") Integer id, @PathVariable("status") Integer status) {
        return clientService.updateStatus(id, status);
    }
    @PostMapping("/uniqueCheck")
    public R checkName(@RequestBody UniqueVo uniqueVo){
        return clientService.checkName(uniqueVo);
    }
    @GetMapping("/exportlogs")
    public R exportlogs() {
        return clientService.exportlogs();
    }

    @GetMapping("/importlogs")
    public R importlogs(MultipartFile file) {
        return clientService.importlogs();
    }
}
